In this assignment you will learn how to control a robot to juggle a ball. To achieve this goal, you will program a velocity controlled robot, such that it causes the ball to bounce with some desired periodic motion. Specifically, you will implement a hybrid controller that uses a mirror control law within the framework of Box 2D, a 2D physics simulator.
This assignment will be broken into the following components:
Robot Juggling Demo
a. Box 2D Simulator
PD-Control of a robot
a. Reference and Error signals
b. Implementing P-controller
c. Implementing a PD-controller
Robot Juggling
a. Ball Dynamics (projectile)
b. Ball dynamics with collision
c. Mirror control law
In [ ]:
from tutorial import *
play_full_solution()
If a window pops up like this picture then you have successfully run the demo.
So what exactly are you looking at? As mentioned previously we are simulating the physics using Box2D.
However, the window that popped up is merely a visulazation of the simulator that uses pygame. Pygame is a software package used to create games in python. It allows the use of keyboard and mouse input. For example, if you hit 'q' or 'esc' the window should close. Note: in OS X the window may not close, however the simulation will stop.
The visulazation is showing an instance of robot juggling.
All of the objects has a local reference frame located in the center of its body.
Our fixed frame is an interial reference frame with $\hat{x}$ increasing to the right and $\hat{y}$ increasing upwards.
All of the objects listed above are rigid bodies that (approximately) obey the laws of physics $\vec{F} = m \vec{a}$. By definition, rigid bodies are not able to penetrate one another.
For every discrete time step, Box2D will attempt to tell us the state (position, velocity, and acceleration) of each body in our domain. During the time step, Box2D will integrate the state of the objects (based on the forces applied). Then, if the state of the objects are in conflict (e.g: overlapping geometry) it will try to resolve the penetration error. The following article goes into more depth about the simulation.
For our purpose, it's important to know that the physics simulator will approximate the state of the world and can have errors in numerical accuracy.